package com.wnhz.work.jy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wnhz.work.jy.R;
import com.wnhz.work.jy.bean.AuctionBean;

import java.util.List;

/**
 * Created by Administrator on 2016/10/8 0008.
 */
public class AuctionAdapter extends BaseAdapter {
    private Context context;
    private List<AuctionBean> auctionList;
    private View.OnClickListener listener;

    public AuctionAdapter(Context context, List<AuctionBean> auctionList, View.OnClickListener listener) {
        this.context = context;
        this.auctionList = auctionList;
        this.listener = listener;
    }


    @Override
    public int getCount() {
        return auctionList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AuctionViewHolder viewHolder = new AuctionViewHolder();
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.auction_item, null);
            viewHolder.imag = (ImageView) convertView.findViewById(R.id.iv_pic);
            viewHolder.title = (TextView) convertView.findViewById(R.id.tv_title);
            viewHolder.content = (TextView) convertView.findViewById(R.id.tv_content);
            viewHolder.price = (TextView) convertView.findViewById(R.id.tv_price);
            viewHolder.tv_rob = (TextView) convertView.findViewById(R.id.tv_rob);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (AuctionViewHolder) convertView.getTag();
        }

//        ImageLoader.getInstance().displayImage(auctionList.get(position).getImage(), viewHolder.imag);
        viewHolder.imag.setImageResource(Integer.parseInt(auctionList.get(position).getImage()));
        viewHolder.title.setText(auctionList.get(position).getTitle());
//        viewHolder.content.setText(auctionList.get(position).getContent());
//        viewHolder.price.setText(auctionList.get(position).getPrice());

        viewHolder.tv_rob.setOnClickListener(listener);

        return convertView;
    }

    class AuctionViewHolder {
        ImageView imag;
        TextView title;
        TextView content;
        TextView price;
        TextView tv_rob;
    }
}
